# 名片管理系统

# 引入函数模块
import card_function

# 提示命令
card_function.tip_command()

# 输入系统指令
while True:
    try:
        command = int(input("请输入指令："))
    except:
        print("请输入正确的命令")
        continue

    # 命令判断
    if command == 1:
        card_function.user_message.append(card_function.insert_card())
    elif command == 2:
        card_function.show_all_user(card_function.user_message)
    elif command == 3:
        name = input("请输入姓名：")
        user_message = card_function.check_user(name, card_function.user_message)
        # 判断此用户是否存在
        if not user_message:
            print("%s不在库中" % name)
            continue
        # 打印用户信息
        card_function.show_all_user(user_message)
        # 操作名片
        new_command = int(input("请输入对名片的操作：1、修改/2、删除/0、返回上一级："))
        if new_command == 1:
            user_variable = card_function.update_user(name, card_function.user_message)
        elif new_command == 2:
            card_function.del_user(name, card_function.user_message)
        else:
            continue
    elif command == 0:
        break
    else:
        print("指令不存在")
